<?php
/**
 * User: 五哥派
 * Date: 2024/7/1
 * Tel(同WX): 17335592719
 */
namespace app\admin\controller\system;

use app\admin\controller\Base;
use app\admin\model\system\Agreement as AgreementModel;
use think\Db;
use think\Exception;

class Agreement extends Base{

    protected $model;

    public function __construct(AgreementModel $model){
        parent::__construct();
        $this->model = $model;
    }
    public function edit(){
        $ids = '1,2,3';
        if(request()->isPost()){
            $data = request()->param();
            Db::startTrans();
            try {
                $list = [
                    ['id'=>1, 'content'=> $data['content0']],
                    ['id'=>2, 'content'=> $data['content1']],
                    ['id'=>3, 'content'=> $data['content2']]
                ];
                $this->model->saveAll($list);
                Db::commit();
                return success('保存成功!');
            }catch (Exception $e){
                Db::rollback();
                return error('保存失败!');
            }

        }

        $where['type'] = ['in', $ids];
        $data = $this->model->queryData($where);
        $this->assign('data',$data);

        return $this->fetch();
    }


}

